<?php
/**
 *@author Connor <caokang@foxmail.com>
 *@todo
 *@link www.zeevin.com
 */
class UserIntro extends CActiveRecord{

	public static function model($className=__CLASS__){
		return parent::model($className);
	}

	public function tableName(){
		return 'user_intro';
	}

	public function rules(){
		return array(
			array('subject','required','message'=>'大标题不能为空'),
			array('content','required','message'=>'正文内容不能为空'),
			array('subject', 'length', 'max'=>255,'message'=>'大标题太长，不能超过255个字符'),
			array('title', 'length', 'max'=>255,'message'=>'小标题太长，不能超过255个字符'),
			);
	}

	public function attributeLabels(){
		return array('subject'=>'大标题：','title'=>'小标题：','content'=>'正文：');
	}

	public function beforeSave(){
		if(parent::beforeSave())
		{
			if($this->isNewRecord)
			{
				$this->ctime=$this->update_time=date('Y-m-d H:i:s');
				$this->uid=Yii::app()->user->id;
			}
			else
				$this->update_time=date('Y-m-d H:i:s');
			return true;
		}
		else
			return false;
	}

}